<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <link th:href="@{/css/Semantic-UI-CSS-master/semantic.css}" href="../../static/css/Semantic-UI-CSS-master/semantic.css" rel="stylesheet" type="text/css">
    <link th:href="@{/css/main.css}" href="../../static/css/main.css" rel="stylesheet" type="text/css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>Title</title>
    <script th:src="@{/js/jquery-3.4.0.js}" src="../../static/js/jquery-3.4.0.js" type="text/javascript"></script>
    <script th:src="@{/css/Semantic-UI-CSS-master/semantic.js}" src="../../static/css/Semantic-UI-CSS-master/semantic.js" type="text/javascript"></script>
    <script th:src="@{/js/main.js}" src="../../static/js/main.js" type="text/javascript"></script>
</head>
<body>
<nav class="ui inverted attached segment" id="nav">
    <div class="ui container">
        <div class="ui inverted secondary menu">
            <h2 class="ui teal header item">Blog后台</h2>
            <a href="/admin/index" class="item active"><i class="home icon"></i> 博客</a>
            <a href="/admin/type" class="item"><i class="idea icon"></i> 分类</a>
            <a href="/admin/tag" class="item"><i class="tags icon"></i> 标签</a>
            <div class="right menu">
                <div class="ui dropdown item">
                    <div class="text"><img th:src="${#httpSession.getAttribute('admin').getImg()}" src="../../static/img/brain.jpg" class="ui avatar image">
                        <span th:text="${#httpSession.getAttribute('admin').getNickname()}">梅迪乌斯</span>
                    </div>
                    <i class="dropdown icon"></i>
                    <div class="menu">
                        <a href="/admin/logout" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</nav>
<div class="ui menu attached pointing">
    <div class="ui center menu container m-margin-huge">
        <a class="item" href="/admin/release">发布</a>
        <a class="item active" href="/admin/index">列表</a>
    </div>
</div>
<div class="m-container-small m-padded-large">
    <div class="ui container">
        <form action="/admin/search" method="get" class="ui segment form">
            <div class="fields">
                <div class="field">
                    <input type="text" name="title" placeholder="标题">
                </div>
                <div class="field">
                    <div class="ui selection dropdown">
                        <input type="hidden" name="typeId">
                        <i class="dropdown icon"></i>
                        <div class="default text">分类</div>
                        <div class="menu">
                            <div th:each="type:${typeList}" class="item" data-value="1" th:data-value="${type.id}" th:text="${type.name}">错误日志</div>
                        </div>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="recommend" name="recommend">
                        <label for="recommend">推荐</label>
                    </div>
                </div>
                <div class="field">
                    <button class="ui teal mini basic button">
                        <i class="search icon"></i>搜索
                    </button>
                </div>
            </div>
        </form>
        <table class="ui table">
            <thead>
            <tr>
                <th width="50px"></th>
                <th width="250px">标题</th>
                <th width="100px">类型</th>
                <th width="105px">推荐</th>
                <th width="100px">更新时间</th>
                <th colspan="2" class="center aligned" width="160px">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="blog:${blogPageInfo.list}">
                <td th:text="${blogStat.count}">1</td>
                <td th:text="${blog.title}">李丹是小居</td>
                <td th:text="${blog.type.name}">生活常识</td>
                <td th:if="${blog.recommend eq '1'}">是</td>
                <td th:unless="${blog.recommend eq '1'}">否</td>
                <td th:text="${blog.updateTime}">2021-01-01</td>
                <td class="center aligned">
                    <form action="/admin/blogUpdate" method="post">
                        <input type="hidden" name="blogId" th:value="${blog.id}">
                        <input type="hidden" name="_method" value="put">
                        <button class="ui button mini teal basic">
                            编辑
                        </button>
                    </form>
                </td>
                <td class="center aligned">
                    <form action="/admin/deleteBlog" method="post">
                        <input type="hidden" name="blogId" th:value="${blog.id}">
                        <input type="hidden" name="_method" value="delete">
                        <button class="ui button mini red basic">
                            删除
                        </button>
                    </form>
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="center aligned">
                <th colspan="7">
                    <div class="ui grid">
                        <div class=" three wide column">
                            <form action="/admin/index" method="get" th:if="${blogPageInfo.prePage>0}">
                                <input type="hidden" name="pageNum" value="1">
                                <button class="ui button mini teal basic item">
                                    首页
                                </button>
                            </form>
                        </div>
                        <div class=" three wide column">
                            <form action="/admin/index" method="get" th:if="${blogPageInfo.prePage>0}">
                                <input type="hidden" name="pageNum" th:value="${blogPageInfo.prePage}">
                                <button class="ui button mini teal basic item">
                                    上一页
                                </button>
                            </form>
                        </div>
                        <div class=" four wide column" th:text="|第${blogPageInfo.pageNum}页/共${blogPageInfo.pages}页|">
                            当前页/总页数
                        </div>
                        <div class=" three wide column">
                            <form action="/admin/index" method="get" th:if="${blogPageInfo.nextPage}>1">
                                <input type="hidden" name="pageNum" th:value="${blogPageInfo.nextPage}">
                                <button class="ui button mini teal basic item">
                                    下一页
                                </button>
                            </form>
                        </div>
                        <div class=" three wide column">
                            <form action="/admin/index" method="get" th:if="${blogPageInfo.pageNum}<${blogPageInfo.pages}">
                                <input type="hidden" name="pageNum" th:value="${blogPageInfo.pages}">
                                <button class="ui button mini teal basic item">
                                    尾页
                                </button>
                            </form>
                        </div>
                    </div>
                </th>
            </tr>
            </tfoot>
        </table>
    </div>
</div>
<script>
    $('.ui.dropdown').dropdown({
        on : 'hover'
    });
</script>
</body>
</html>